package vista;

import controlador.ControladorListadoIngrediente;
import controlador.ControladorListadoProducto;

import java.awt.event.ActionListener;
import java.util.Vector;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.border.BevelBorder;
import javax.swing.table.DefaultTableModel;

import modelo.Producto;


/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class VentanaListadoProducto extends javax.swing.JFrame {
    private ControladorListadoProducto control;
    private DefaultTableModel modeloTabla;
    private Vector<String> fila;
  
  
    public VentanaListadoProducto() {
        initComponents();
        modeloTabla= new DefaultTableModel();
        tblProducto.setModel(modeloTabla);

        fila= new Vector<String>();

        fila.add("Producto");
        fila.add("Monto Total Generado");
        fila.add("Cantidad Total Vendida");
        modeloTabla.setColumnIdentifiers(fila);

       
        control = new  ControladorListadoProducto(this);
        addAction();
    }

     public void addListener(ActionListener escuchador){
        btnSalir.addActionListener(escuchador);
        btnConsultar.addActionListener(escuchador);
        chcAsc.addActionListener(escuchador);
        chcDes.addActionListener(escuchador);
    }

    public void addAction(){
          btnConsultar.setActionCommand("Consultar");
        btnSalir.setActionCommand("Salir");
        chcAsc.setActionCommand("Asc");
        chcDes.setActionCommand("Des");;
    }


    public void agregar(String[] dato){
        fila = new Vector<String>();
        fila.add(dato[0]);
        fila.add(dato[1]);
        fila.add(dato[2]);
        
        modeloTabla.addRow(fila);

        }

    public DefaultTableModel getModeloTabla() {
        return modeloTabla;
    }
    

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        buttonGroup1 = new javax.swing.ButtonGroup();
        jScrollPane2 = new javax.swing.JScrollPane();
        tblProducto = new javax.swing.JTable();
        btnConsultar = new javax.swing.JButton();
        btnSalir = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();
        chcAsc = new javax.swing.JCheckBox();
        chcDes = new javax.swing.JCheckBox();
        jLabel4 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        getContentPane().setLayout(null);

        tblProducto.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        jScrollPane2.setViewportView(tblProducto);

        getContentPane().add(jScrollPane2);
        jScrollPane2.setBounds(12, 61, 452, 360);
        jScrollPane2.setBackground(new java.awt.Color(255,255,255));

        btnConsultar.setFont(new java.awt.Font("Ubuntu",1,15)); // NOI18N
        btnConsultar.setText("Consultar");
        getContentPane().add(btnConsultar);
        btnConsultar.setBounds(104, 433, 100, 23);

        btnSalir.setFont(new java.awt.Font("Ubuntu",1,15)); // NOI18N
        btnSalir.setText("Salir");
        getContentPane().add(btnSalir);
        btnSalir.setBounds(274, 433, 100, 23);

        jLabel1.setFont(new java.awt.Font("Ubuntu",1,15)); // NOI18N
        jLabel1.setText("Orden del Listado");
        getContentPane().add(jLabel1);
        jLabel1.setBounds(20, 35, 168, 24);

        buttonGroup1.add(chcAsc);
        chcAsc.setFont(new java.awt.Font("Ubuntu",1,15)); // NOI18N
        chcAsc.setText("Ascendente");
        getContentPane().add(chcAsc);
        chcAsc.setBounds(200, 36, 122, 21);
        chcAsc.setBackground(new java.awt.Color(255,255,255));

        buttonGroup1.add(chcDes);
        chcDes.setFont(new java.awt.Font("Ubuntu",1,15)); // NOI18N
        chcDes.setText("Descendente");
        getContentPane().add(chcDes);
        chcDes.setBounds(333, 34, 126, 22);
        chcDes.setBackground(new java.awt.Color(255,255,255));

        jLabel4.setFont(new java.awt.Font("Ubuntu",1,15));
        jLabel4.setText("Productos Vendidos");
        getContentPane().add(jLabel4);
        jLabel4.setBounds(168, 6, 201, 22);

        java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
        this.setBounds(0, 0, 483, 503);
        this.setTitle("Listado de Productos Vendidos");
        getContentPane().setBackground(new java.awt.Color(255,255,255));
    }// </editor-fold>//GEN-END:initComponents

   
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new VentanaListadoProducto().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnConsultar;
    private javax.swing.JButton btnSalir;
    private javax.swing.ButtonGroup buttonGroup1;
    private javax.swing.JCheckBox chcAsc;
    private javax.swing.JCheckBox chcDes;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JTable tblProducto;
    // End of variables declaration//GEN-END:variables

}
